<template>
  <div style="height: 100%;">
    <div class="top-nav">
      <van-tabs title-active-color="#3A7FE2" color="#3A7FE2">
        <van-tab title="收到通知">
          <messageList :messages="receiveMessage"/>
        </van-tab>
        <van-tab title="发出通知">
          <messageList :messages="sendMessage"/>
        </van-tab>
      </van-tabs>
    </div>
<!--    <router-link to="/message/send">
      <div class="plus"><van-icon name="plus" /></div>
    </router-link> -->
  </div>
</template>

<script>
import messageList from '@/components/messageList'
import api from '@/api'
export default {
  name: 'course-message',
  data () {
    return {
      receiveMessage: [],
      sendMessage: []
    }
  },
  methods: {
    // 收到的消息  消息获取接口 agencyMessageManagement
    select () {
      let params = {
        id: JSON.parse(sessionStorage.getItem('user')).id,
        // id: localStorage.getItem('subsidiary'),
        type: 1
      }
      api.agencyMessageManagement({
        params,
        callback: res => {
          this.receiveMessage = res.data.data
          console.log(res.data.data)
        }
      })
    },
    // 发出的消息
    selectSendMsg () {
      let params = {
        id: JSON.parse(sessionStorage.getItem('user')).id
        // id: localStorage.getItem('subsidiary'),
      }
      api.agencyMessageManagementSend({
        params,
        callback: res => {
          this.sendMessage = res.data.data
          console.log(res.data.data)
        }
      })
    }

  },
  components: {
    messageList
  },
  created () {
    this.select()
    this.selectSendMsg()
  }
}
</script>

<style scoped>
  .top-nav{
    height: 100%;
  }
  .plus{
    position: fixed;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #000;
  }
  .van-tabs{
    height: 100%;
  }
  .van-tabs div:nth-child(2){
    height: 100%;
  }
</style>
